const fs = require("fs");
const path = require("path");
const Handlebars = require("handlebars");

// 读取 Vue 文件模板
const templatePath = path.join(__dirname + "/templates/", "baseForm.hbs");
const templateContent = fs.readFileSync(templatePath, "utf-8");

// 定义要生成的页面数据
const pages = [
  {
    name: "test",
    title: "test",
    class: `.Panel {
    padding: 10px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    font-family: "苹方简M";
  }`,
  },
  // 可以添加更多页面配置
];

// 编译 Handlebars 模板
const template = Handlebars.compile(templateContent);

// 生成每个页面对应的 Vue 文件
pages.forEach((page) => {
  const vueContent = template({
    title: page.title,
    componentName: page.name,
    class: page.class,
  });

  const outputPath = path.join(__dirname, `${page.name}.vue`);
  fs.writeFileSync(outputPath, vueContent, "utf-8");
  console.log(`Generated ${page.name}.vue`);
});
